package com.yungu.swift.system.finance.model.enums;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author : cuixiuyin
 * @date : 2019/8/26
 */
public enum FinanceEnum {

    /**
     * 10 充值
     */
    TENPAY_RECHARGE("1001", "微信账户充值"),
    ALIPAY_RECHARGE("1002", "支付宝账户充值"),
    PRESENT_RECHARGE("1003", "平台赠送充值"),
    RECHARGE_TO_PASSENGER_ACCOUNT("1004", "乘客充值实际到账"),

    /**
     * 20 支付
     */
    PASSENGER_RECHARGE_BALANCE_PAY("20010101", "乘客充值余额支付"),
    PASSENGER_PRESENT_BALANCE_PAY("20010102", "乘客赠送余额支付"),
    PASSENGER_TEN_PAY("200102", "乘客微信支付"),
    PASSENGER_ALI_PAY("200103", "乘客支付宝支付"),
    DRIVER_BALANCE_PAY("200201", "司机余额支付"),
    DRIVER_TEN_PAY("200202", "司机微信支付"),
    DRIVER_ALI_PAY("200203", "司机支付宝支付"),
    MARKET_FULL_PAY("200301", "优惠券全额抵扣"),
    MARKET_PART_PAY("200302", "优惠券部分抵扣"),

    /**
     * 30 活动奖励
     */
    DRIVER_INVITE_DRIVER_INVITE_REWARD("30010101", "司机邀请司机邀请者奖励"),
    DRIVER_INVITE_DRIVER_INVITED_REWARD("30010102", "司机邀请司机被邀请者奖励"),
    DRIVER_INVITE_PASSENGER_INVITE_REWARD("30010201", "司机邀请乘客邀请者奖励"),
    DRIVER_INVITE_PASSENGER_INVITED_REWARD("30010202", "司机邀请乘客被邀请者奖励"),

    /**
     * 40 提现
     */
    WITHDRAWAL_TO_BANK_CARD("4001", "提现到银行卡"),
    WITHDRAWAL_TO_TEN("4002", "提现到微信"),
    WITHDRAWAL_TO_ALI("4003", "提现到支付宝"),
    WITHDRAWAL_POUNDAGE("4004", "提现手续费"),
    WITHDRAWAL_BACK_BANK_CARD("4005", "提现到银行卡退回"),
    WITHDRAWAL_BACK_TEN("4006", "提现到微信退回"),
    WITHDRAWAL_BACK_ALI("4007", "提现到支付宝退回"),
    WITHDRAWAL_BACK_POUNDAGE("4008", "提现手续费退回"),
    /**
     * 50 分润抽成
     */
    PLATFORM_EXTRACT("5001", "平台分润抽成"),
    AGENT_EXTRACT("5002", "代理分润抽成"),
    COMPANY_EXTRACT("5003", "企业分润抽成"),
    DRIVER_EXTRACT("5004", "司机分润抽成"),

    /**
     * 70 退款
     */
    PLATFORM_EXTRACT_REFUND("70010102", "平台分润退款"),
    AGENT_EXTRACT_REFUND("70010103", "代理分润退款"),
    COMPANY_EXTRACT_REFUND("70010104", "企业分润退款"),
    DRIVER_EXTRACT_REFUND("70010105", "司机分润退款"),
    PLATFORM_REFUND_TO_PASSENGER_RECHARGE("700101061", "平台退款给乘客充值余额"),
    PLATFORM_REFUND_TO_PASSENGER_PRESENT("700101062", "平台退款给乘客赠送余额"),
    PLATFORM_REFUND_TO_PASSENGER_TENPAY("700101063", "平台退款到乘客微信账户"),
    PLATFORM_REFUND_TO_PASSENGER_ALIPAY("700101064", "平台退款到乘客支付宝账户"),
    PLATFORM_PART_EXTRACT_REFUND("70010202", "平台分润部分退款"),
    AGENT_PART_EXTRACT_REFUND("70010203", "代理分润部分退款"),
    COMPANY_PART_EXTRACT_REFUND("70010204", "企业分润部分退款"),
    DRIVER_PART_EXTRACT_REFUND("70010205", "司机分润部分退款"),
    PLATFORM_PART_REFUND_TO_PASSENGER_RECHARGE("700102061", "平台部分退款给乘客充值余额"),
    PLATFORM_PART_REFUND_TO_PASSENGER_PRESENT("700102062", "平台部分退款给乘客赠送余额"),
    PLATFORM_PART_REFUND_TO_PASSENGER_TENPAY("700102063", "平台部分退款到乘客微信账户"),
    PLATFORM_PART_REFUND_TO_PASSENGER_ALIPAY("700102064", "平台部分退款到乘客支付宝账户"),
    MARKET_REFUND("70010301", "优惠券全额退款"),
    MARKET_PART_REFUND("70010302", "优惠券部分退款"),
    ADD_FEE_REFUND("70010401", "司机附加费退款"),
    ADD_FEE_PART_REFUND("70010402", "司机附加费部分退款"),
    RECHARGE_PRINCIPAL_REFUND("70020101", "充值本金退款"),
    RECHARGE_PRESENT_REFUND("70020102", "充值赠送退款"),

    /**
     * 80 奖惩
     */
    DRIVER_REWARD("800101", "司机奖励"),
    DRIVER_PUNISHMENT("800102", "司机惩罚"),
    PASSENGER_COMPENSATION("800201", "乘客补偿"),
    ADD_DRIVER_CAN_FROWARD_BALANCE("80030101", "后台增加司机提现余额"),
    REDUCE_DRIVER_CAN_FROWARD_BALANCE("80030102", "后台减少司机提现余额"),
    ADD_DRIVER_FROZEN_BALANCE("80030201", "后台增加司机冻结余额"),
    REDUCE_DRIVER_FROZEN_BALANCE("80030202", "后台减少司机冻结余额"),
    ADD_PASSENGER_RECHARGE_BALANCE("80040101", "后台增加乘客充值余额"),
    REDUCE_PASSENGER_RECHARGE_BALANCE("80040102", "后台减少乘客充值余额"),
    ADD_PASSENGER_PRESENT_BALANCE("80040201", "后台增加乘客赠送余额"),
    REDUCE_PASSENGER_PRESENT_BALANCE("80040202", "后台减少乘客赠送余额"),

    /**
     * 90 保险费
     */
    DRIVER_ADDITIONAL_FEE("9001", "司机附加费"),
    ;

    private String code;
    private String msg;

    FinanceEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * key:code
     * value:msg
     */
    private static Map<String, String> MAP = new HashMap<>(16);

    public static String getMsg(String code) {
        if (MAP == null || MAP.size() == 0) {
            FinanceEnum[] financeEnums = FinanceEnum.values();
            for (FinanceEnum financeEnum : financeEnums) {
                MAP.put(financeEnum.code, financeEnum.msg);
            }
        }
        Set<String> set = StringUtils.commaDelimitedListToSet(code);
        StringBuilder buffer = new StringBuilder();
        for (String subCode : set) {
            buffer.append(MAP.get(subCode));
        }
        return buffer.toString();
    }
}
